package com.tiny.work.plane;

import java.math.BigDecimal;

public class IrritableModel extends NormalModel {

    /**
     * 耗油量 单位 t/t/km
     */
    BigDecimal oilPerKmIrritable;

    /**
     * 飞行速度 单位 h/km
     */
    BigDecimal hourPerKmIrritable;


    @Override
    public PlaneResult algorithm(BigDecimal journey, BigDecimal weight) {
        PlaneResult algorithm = super.algorithm(journey, weight);
        BigDecimal overtimeJour = journey.subtract(hourPerKm.multiply(Constants.EIGHT_HOUR_DAY));
        BigDecimal oilPerDay = overtimeJour.multiply(weight).multiply(oilPerKm);
        BigDecimal time = overtimeJour.multiply(hourPerKm);
        return new PlaneResult(
            oilPerDay.intValue() + algorithm.getTotalOilPerDay(),
            time.intValue() + algorithm.getTotalTimePerDay());
    }

    @Override
    public boolean isMatch(Context context) {
        BigDecimal hours = context.getJourney().divide(hourPerKm);
        if (hours.compareTo(Constants.EIGHT_HOUR_DAY) <= 0) {
            return false;
        }
        return true;
    }

    public IrritableModel() {
    }



    public IrritableModel(BigDecimal oilPerKm, BigDecimal hourPerKm, BigDecimal oilPerKmIrritable,
        BigDecimal hourPerKmIrritable) {
        super(oilPerKm, hourPerKm);
        this.oilPerKmIrritable = oilPerKmIrritable;
        this.hourPerKmIrritable = hourPerKmIrritable;
    }

    public IrritableModel(BigDecimal oilPerKmIrritable, BigDecimal hourPerKmIrritable) {
        this.oilPerKmIrritable = oilPerKmIrritable;
        this.hourPerKmIrritable = hourPerKmIrritable;
    }

    public BigDecimal getOilPerKmIrritable() {
        return oilPerKmIrritable;
    }

    public IrritableModel setOilPerKmIrritable(BigDecimal oilPerKmIrritable) {
        this.oilPerKmIrritable = oilPerKmIrritable;
        return this;
    }

    public BigDecimal getHourPerKmIrritable() {
        return hourPerKmIrritable;
    }

    public IrritableModel setHourPerKmIrritable(BigDecimal hourPerKmIrritable) {
        this.hourPerKmIrritable = hourPerKmIrritable;
        return this;
    }
}
